if [ -n "$1" ]; then
    data_date=$1
else
  data_date=`date -d "-1 days" +%F`
fi

sqoop import \
--connect jdbc:mysql://node101:3306/jtp_ads \
--username root \
--password 123456 \
--fields-terminated-by '\001' \
--as-textfile \
--query 'SELECT id,product_id,material_id,group_id,ad_name,materail_url FROM ads WHERE $CONDITIONS AND 1=1' \
--target-dir "hdfs://node101:8020/warehouse/app_basic/${data_date}/t_ads_ads" \
--delete-target-dir \
--null-non-string '\\N' \
--null-string '\\N' \
--num-mappers 1

sqoop import \
--connect jdbc:mysql://node101:3306/jtp_ads \
--username root \
--password 123456 \
--fields-terminated-by '\001' \
--as-textfile \
--query 'SELECT id,ad_id,platform_id,create_time,cancel_time FROM ads_platform WHERE $CONDITIONS AND 1=1' \
--target-dir "hdfs://node101:8020/warehouse/app_basic/${data_date}/t_ads_ads_platform" \
--delete-target-dir \
--null-non-string '\\N' \
--null-string '\\N' \
--num-mappers 1

sqoop import \
--connect jdbc:mysql://node101:3306/jtp_ads \
--username root \
--password 123456 \
--fields-terminated-by '\001' \
--as-textfile \
--query 'SELECT id,platform,platform_alias_zh FROM platform_info WHERE $CONDITIONS AND 1=1' \
--target-dir "hdfs://node101:8020/warehouse/app_basic/${data_date}/t_ads_platform_info" \
--delete-target-dir \
--null-non-string '\\N' \
--null-string '\\N' \
--num-mappers 1

sqoop import \
--connect jdbc:mysql://node101:3306/jtp_ads \
--username root \
--password 123456 \
--fields-terminated-by '\001' \
--as-textfile \
--query 'SELECT id,name,price FROM product WHERE $CONDITIONS AND 1=1' \
--target-dir "hdfs://node101:8020/warehouse/app_basic/${data_date}/t_ads_product" \
--delete-target-dir \
--null-non-string '\\N' \
--null-string '\\N' \
--num-mappers 1